#include "TaskQueue.h"
#include <future>
#include <iostream>

template<typename T>
int task(T&& n) {
    return std::forward<T>(n);
}

int main() {
    typedef int (*Task)(int&&);
    Task t = task;
    int temp_task;
    TaskQueue pTaskQueue;
    std::cout << "Main" << " thread = " << std::this_thread::get_id() << " start!" << std::endl;

    std::future<void> result1 = std::async(&TaskQueue::push_queue, &pTaskQueue, t(1));
    result1.wait();
    std::future<void> result2 = std::async(&TaskQueue::pop_queue, &pTaskQueue, temp_task);
    result2.wait();

    std::cout << "任务队列"; 
    if (pTaskQueue.empty()) {
        std::cout << "为空!" << std::endl;
    } else {
        std::cout << "非空!" << std::endl;
    }
    std::cout << std::endl;

    std::cout << "任务队列有" << pTaskQueue.size() << "个任务" << std::endl;
    std::cout << std::endl;

    std::cout << "Main" << " thread = " << std::this_thread::get_id() << " end!" << std::endl;
    return 0;
}
